home *** CD-ROM | disk | FTP | other *** search
- Path: news.isys.net!usenet
- From: Henrik.Stellmann@Hamburg.NetSurf.DE (Henrik)
- Newsgroups: comp.lang.c++
- Subject: Re: How to the size of a file in C ?
- Date: Sun, 11 Feb 1996 20:19:37 +0100
- Organization: iSYS Informationssystem Hamburg
- Message-ID: <4flcj7$66h@trance.isys.net>
- References: <4ffeqa$pjh@brtph500.bnr.ca>
- NNTP-Posting-Host: dip101-1.hamburg.netsurf.de
- X-Newsreader: Forte Free Agent v0.38
-
- Gilbert Banks <gilbertb@bnr.ca> wrote:
-
- >How do I get the size of a file in C UNIX-based? I tried sizeof <file>, but
-
- try this:
-
- long FileSize (const char * FileName)
- {
- lont Fsize;
-
- FILE * File = fopen(FileName)
- if (File)
- {
- Fsize= fseek (File, 0, *** );
- fclose (File);
- return FSize;
- }
- else
- {
- return -1;
- }
-
- }
-
-
- *** Sorry, I don't remember the name of the constant to make fseek
-
- jump relative to the fileend. Please look in your C - reference for
- fseek.
-
- It's not the fastet way, and sure not sooo elegant. But it works.
- Maybe others have better ideas.
-
-
- Henrik :-)
-
-
-
-